<?php


namespace App\Sevrice;


class BaiDu
{
    protected $appId;
    protected $apiKey;
    protected $secretKey;

    function __construct()
    {
        $this->appId = env('BAIDUAPPID');
        $this->apiKey = env('BAIDUAPIKEY');
        $this->secretKey = env('BAIDUSECRETKEY');
    }

    /**
     * @param $data
     * @return bool
     * 验证文本内容弄是否合规
     */
    function conclusion($data)
    {
        $client = new \Luffy\TextCensor\Core($this->appId, $this->apiKey, $this->secretKey);
        $res = $client->textCensorUserDefined($data); //待审核文本字符串
        if ($res['conclusion'] == '不合规') {
            return false;
        }
        return true;
    }
}